package com.fenqing.leetcode.code.t1300_1400;

import com.fenqing.annotations.Execute;
import com.fenqing.bean.TreeNode;
import com.fenqing.core.Topic;

/**
 * @author fenqing
 */
public class Topic1379 extends Topic {

    /**
     * 构造器
     *
     * @param input1 输入1
     * @param input2 输入2
     * @param input3 输入3
     */
    public Topic1379(String input1, String input2, String input3) {
        super(input1, input2, input3);
    }

    @Execute
    public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {
        if (original == null) {
            return null;
        }
        if (cloned == null) {
            return null;
        }
        if (original == target) {
            return cloned;
        }
        TreeNode left = getTargetCopy(original.left, cloned.left, target);
        if (left != null) {
            return left;
        }
        return getTargetCopy(original.right, cloned.right, target);
    }

    public static void main(String[] args) {
        Topic1379 topic1379 = new Topic1379("[7,4,3,null,null,6,19]", "[7,4,3,null,null,6,19]", "");
        TreeNode run = topic1379.run();
        System.out.println(run);
    }

}
